<template>
  <div class="modal-overlay" @click.self="$emit('close')">
    <div class="modal-content">
      <div class="modal-header">
        <h3>AI智能调度建议</h3>
        <button class="close-btn" @click="$emit('close')">×</button>
      </div>
      <div class="modal-body">
        <p class="suggestion-text">根据当前事件类型和警员状态，AI建议指派警员：</p>
        <div class="officer-recommendation">
          {{ suggestion.officerName }} ({{ suggestion.department }})
        </div>
        <p class="reason-title">推荐理由：</p>
        <p class="reason-text">{{ suggestion.reason }}</p>
      </div>
      <div class="modal-footer">
        <button class="btn btn-primary" @click="$emit('confirm')">确定</button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
const props = defineProps<{
  suggestion: {
    officerName: string;
    department: string;
    reason: string;
  }
}>();

const emit = defineEmits(['close', 'confirm']);
</script>

<style scoped>
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background-color: #fff;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid #ebeef5;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #303133;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #909399;
  cursor: pointer;
  outline: none;
}

.modal-body {
  padding: 24px;
}

.suggestion-text {
  font-size: 16px;
  color: #606266;
  margin-bottom: 16px;
}

.officer-recommendation {
  font-size: 20px;
  font-weight: 600;
  color: #303133;
  margin-bottom: 20px;
  padding: 12px 16px;
  background-color: #f5f7fa;
  border-radius: 4px;
  display: inline-block;
}

.reason-title {
  font-size: 16px;
  font-weight: 500;
  color: #303133;
  margin: 16px 0 8px;
}

.reason-text {
  font-size: 14px;
  color: #606266;
  line-height: 1.5;
  background-color: #f9fafc;
  padding: 12px 16px;
  border-radius: 4px;
  white-space: pre-wrap;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #ebeef5;
  display: flex;
  justify-content: flex-end;
}

.btn {
  padding: 8px 20px;
  border-radius: 4px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.btn-primary {
  background-color: #409eff;
  color: #fff;
}

.btn-primary:hover {
  background-color: #66b1ff;
}
</style>
